﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Default2 : System.Web.UI.Page
{
    Controllers controller;
    List<SanBay> listSanBayDi;

    protected void Page_Load(object sender, EventArgs e)
    {
        controller = new Controllers();
        if (!IsPostBack)
        {
            LoadSanBay();
        }
        
        
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string tenSBdi = DropDownList1.SelectedItem.Text;
        string soChon = DropDownList2.SelectedItem.Text;
        MessageBox("Ten san bay di la: " + tenSBdi + " | so chon la: " + soChon);
    }

    private void MessageBox(string msg)
    {
        Page.Controls.Add(new LiteralControl("<script language='javascript'> window.alert(\"" + msg + "\"); <" + "/script>"));
    }

    private void LoadSanBay()
    {
        listSanBayDi = new List<SanBay>();

        //load sân bây đi
        listSanBayDi = controller.TimSanBayDi();

        DropDownList1.Items.Clear();
        foreach (SanBay sb in listSanBayDi)
        {
            DropDownList1.Items.Add(sb.TenSanBay);
        }
    }
}